<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="public/admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="public/admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link href="public/admin/Flat/docs/assets/css/demo.css" rel="stylesheet">
	    <link rel="shortcut icon" href="public/admin/Flat/img/favicon.ico">
	    <script src="resource/hdjs/js/jquery.min.js"></script>
	    <script src="resource/hdjs/js/bootstrap.min.js"></script>
	    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
	    <!--[if lt IE 9]>
	      <script src="dist/js/vendor/html5shiv.js"></script>
	      <script src="dist/js/vendor/respond.min.js"></script>
	    <![endif]-->
	    <style type="text/css">
	    	.modal-sm{width:400px;}
	    </style>
	</head>
	<body>
		<table class="table table-hover">
			<tr class="active">
			  订单列表
			</tr>
			<tr class="active">
			  <th width="30">oid</th>
			  <th width="100">订单号</th>
			  <th>收货人</th>
			  <th>收货地址</th>
			  <th>手机号</th>
			  <th>订单时间</th>
			  <th>金额</th>
			  <th>备注信息</th>
			  <th>订单状态</th>
			  <th width="300">操作</th>
			</tr>
			<?php foreach ((array)$data as $k=>$v){?>
			<tr>
				<td><?php echo $v['oid']?></td>
				<td><?php echo $v['number']?></td>
				<td><?php echo $v['consignee']?></td>
				<td><?php echo $v['address']?></td>
				<td><?php echo $v['mobile']?></td>
				<td><?php echo date('Y-m-d',$v['time'])?></td>
				<td><?php echo $v['total']?></td>
				<td><?php echo $v['remark']?></td>
				
				<td><?php echo $v['status']?></td>
				
				<td>
					<a href="<?php echo U('orderlist/orderlist',array('oid'=>$v['oid']))?>" class="btn btn-sm btn-warning">订单列表</a>
					<a href="javascript:;" name="<?php echo $v['oid']?>" data-target=".bs-example-modal-sm" data-toggle="modal" class="btn btn-sm btn-warning edit">编辑</a>
					
					<a href="javascript:if(confirm('确认彻底删除吗?')) location.href='<?php echo U('orderlist/del',array('oid'=>$v['oid']))?>';" class="btn btn-sm btn-danger">彻底删除</a>
				</td>
			</tr>
			<?php }?>
		</table>
		
		
	<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
	<form action="<?php echo U('edit')?>" method="post" id="form" onsubmit="return add();">
  <div class="modal-dialog modal-sm">
    <div class="modal-content" style="padding: 30px;">
    
      
    </div>
  </div>
	</form>
  
</div>	
		
	<script type="text/javascript">
	$(function(){
		$('.edit').click(function(){
			This=$(this).parents('tr').html();
//			alert(This);
			var oid=$(this).attr('name');
//			alert(oid);
			$.ajax({
				type:"post",
				url:"<?php echo U('listData')?>",
				data:{oid:oid},
				success:function(phpData){
					var str='';
					if(!phpData.valid){
						return;
					}
//					alert(phpData);
					str+='<table class="table table-hover" border="0" cellspacing="0" cellpadding="0"><tr>订单ID:'+phpData.message.oid+'</tr>';
					str+='<tr><td>订单号：</td><td><input readonly="readonly" type="text" value="'+phpData.message.number+'" /></td></tr>';
					str+='<tr><td>收货人：</td><td><input type="text" name="consignee" id="" value="'+phpData.message.consignee+'" /></td></tr>';
					str+='<tr><td>收货地址：</td><td><input style="width:220px;" type="text" name="address" id="" value="'+phpData.message.address+'" /></td></tr>';
					str+='<tr><td>手机号：</td><td><input type="text" name="mobile" id="" value="'+phpData.message.mobile+'" /></td></tr>';
					str+='<tr><td>金额：</td><td><input type="text" name="total" id="" value="'+phpData.message.total+'" /></td></tr>';
					str+='<tr><td>订单状态：</td><td><select name="status"><option value='+phpData.message.status+'>'+phpData.message.status+'</option><option value="未付款">未付款</option><option value="待发货">待发货</option><option value="已发货">已发货</option><option value="已完成">已完成</option><option value="货到付款">货到付款</option></select></td></tr>';
					str+='<input type="hidden" name="oid" id="oid" value="'+phpData.message.oid+'" /></table>';
					str+='<input style="margin-left: 140px;" class="btn btn-sm btn-warning" type="submit" value="提 交"/>';
      			$('.modal-content').html(str);
				}
			});
		})
		
	})
</script>	
<script type="text/javascript">
		function edit(){
//			序列化表单数据serialize()
			var oid=$('input[name=oid]').val();
			var data=$('#form').serialize();
			$.post("<?php echo U('edit',array('oid'=>oid))?>",data,function(phpData){
				require(['util'],function(util){
					
				});
			},'json');
		}
	</script>		
		
		
	</body>
</html>
